\(\int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx\) [25]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 24, antiderivative size = 90 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-4 a^3 x+\frac {4 i a^3 \log (\cos (c+d x))}{d}+\frac {2 a^3 \tan (c+d x)}{d}-\frac {i a (a+i a \tan (c+d x))^2}{2 d}-\frac {i (a+i a \tan (c+d x))^4}{4 a d} \]

[Out]

-4*a^3*x+4*I*a^3*ln(cos(d*x+c))/d+2*a^3*tan(d*x+c)/d-1/2*I*a*(a+I*a*tan(d*x+c))^2/d-1/4*I*(a+I*a*tan(d*x+c))^4
/a/d

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3624, 3559, 3558, 3556} \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=\frac {2 a^3 \tan (c+d x)}{d}+\frac {4 i a^3 \log (\cos (c+d x))}{d}-4 a^3 x-\frac {i (a+i a \tan (c+d x))^4}{4 a d}-\frac {i a (a+i a \tan (c+d x))^2}{2 d} \]

[In]

Int[Tan[c + d*x]^2*(a + I*a*Tan[c + d*x])^3,x]

[Out]

-4*a^3*x + ((4*I)*a^3*Log[Cos[c + d*x]])/d + (2*a^3*Tan[c + d*x])/d - ((I/2)*a*(a + I*a*Tan[c + d*x])^2)/d - (
(I/4)*(a + I*a*Tan[c + d*x])^4)/(a*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3559

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((a + b*Tan[c + d*x])^(n - 1)/(d*(n - 1))
), x] + Dist[2*a, Int[(a + b*Tan[c + d*x])^(n - 1), x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[a^2 + b^2, 0] && G
tQ[n, 1]

Rule 3624

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[
d^2*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Simp[c^2 - d^2 + 2*c*d*Tan[e
 + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] &&  !LeQ[m, -1] &&  !(EqQ[m, 2] && EqQ
[a, 0])

Rubi steps \begin{align*} \text {integral}& = -\frac {i (a+i a \tan (c+d x))^4}{4 a d}-\int (a+i a \tan (c+d x))^3 \, dx \\ & = -\frac {i a (a+i a \tan (c+d x))^2}{2 d}-\frac {i (a+i a \tan (c+d x))^4}{4 a d}-(2 a) \int (a+i a \tan (c+d x))^2 \, dx \\ & = -4 a^3 x+\frac {2 a^3 \tan (c+d x)}{d}-\frac {i a (a+i a \tan (c+d x))^2}{2 d}-\frac {i (a+i a \tan (c+d x))^4}{4 a d}-\left (4 i a^3\right ) \int \tan (c+d x) \, dx \\ & = -4 a^3 x+\frac {4 i a^3 \log (\cos (c+d x))}{d}+\frac {2 a^3 \tan (c+d x)}{d}-\frac {i a (a+i a \tan (c+d x))^2}{2 d}-\frac {i (a+i a \tan (c+d x))^4}{4 a d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.44 (sec) , antiderivative size = 67, normalized size of antiderivative = 0.74 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-\frac {i a^3 \left (1+16 \log (i+\tan (c+d x))+16 i \tan (c+d x)-8 \tan ^2(c+d x)-4 i \tan ^3(c+d x)+\tan ^4(c+d x)\right )}{4 d} \]

[In]

Integrate[Tan[c + d*x]^2*(a + I*a*Tan[c + d*x])^3,x]

[Out]

((-1/4*I)*a^3*(1 + 16*Log[I + Tan[c + d*x]] + (16*I)*Tan[c + d*x] - 8*Tan[c + d*x]^2 - (4*I)*Tan[c + d*x]^3 +
Tan[c + d*x]^4))/d

Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 72, normalized size of antiderivative = 0.80

method result size
derivativedivides \(\frac {a^{3} \left (4 \tan \left (d x +c \right )-\frac {i \left (\tan ^{4}\left (d x +c \right )\right )}{4}-\left (\tan ^{3}\left (d x +c \right )\right )+2 i \left (\tan ^{2}\left (d x +c \right )\right )-2 i \ln \left (1+\tan ^{2}\left (d x +c \right )\right )-4 \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(72\)
default \(\frac {a^{3} \left (4 \tan \left (d x +c \right )-\frac {i \left (\tan ^{4}\left (d x +c \right )\right )}{4}-\left (\tan ^{3}\left (d x +c \right )\right )+2 i \left (\tan ^{2}\left (d x +c \right )\right )-2 i \ln \left (1+\tan ^{2}\left (d x +c \right )\right )-4 \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(72\)
parallelrisch \(-\frac {i a^{3} \left (\tan ^{4}\left (d x +c \right )\right )-8 i a^{3} \left (\tan ^{2}\left (d x +c \right )\right )+4 a^{3} \left (\tan ^{3}\left (d x +c \right )\right )+8 i a^{3} \ln \left (1+\tan ^{2}\left (d x +c \right )\right )+16 a^{3} d x -16 a^{3} \tan \left (d x +c \right )}{4 d}\) \(83\)
risch \(\frac {8 a^{3} c}{d}+\frac {2 i a^{3} \left (12 \,{\mathrm e}^{6 i \left (d x +c \right )}+23 \,{\mathrm e}^{4 i \left (d x +c \right )}+18 \,{\mathrm e}^{2 i \left (d x +c \right )}+5\right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {4 i a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{d}\) \(89\)
norman \(-4 a^{3} x +\frac {4 a^{3} \tan \left (d x +c \right )}{d}-\frac {a^{3} \left (\tan ^{3}\left (d x +c \right )\right )}{d}+\frac {2 i a^{3} \left (\tan ^{2}\left (d x +c \right )\right )}{d}-\frac {i a^{3} \left (\tan ^{4}\left (d x +c \right )\right )}{4 d}-\frac {2 i a^{3} \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}\) \(92\)
parts \(\frac {a^{3} \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}-\frac {i a^{3} \left (\frac {\left (\tan ^{4}\left (d x +c \right )\right )}{4}-\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}+\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}+\frac {3 i a^{3} \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}-\frac {3 a^{3} \left (\frac {\left (\tan ^{3}\left (d x +c \right )\right )}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(135\)

[In]

int(tan(d*x+c)^2*(a+I*a*tan(d*x+c))^3,x,method=_RETURNVERBOSE)

[Out]

1/d*a^3*(4*tan(d*x+c)-1/4*I*tan(d*x+c)^4-tan(d*x+c)^3+2*I*tan(d*x+c)^2-2*I*ln(1+tan(d*x+c)^2)-4*arctan(tan(d*x
+c)))

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 177 vs. \(2 (76) = 152\).

Time = 0.24 (sec) , antiderivative size = 177, normalized size of antiderivative = 1.97 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-\frac {2 \, {\left (-12 i \, a^{3} e^{\left (6 i \, d x + 6 i \, c\right )} - 23 i \, a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} - 18 i \, a^{3} e^{\left (2 i \, d x + 2 i \, c\right )} - 5 i \, a^{3} + 2 \, {\left (-i \, a^{3} e^{\left (8 i \, d x + 8 i \, c\right )} - 4 i \, a^{3} e^{\left (6 i \, d x + 6 i \, c\right )} - 6 i \, a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} - 4 i \, a^{3} e^{\left (2 i \, d x + 2 i \, c\right )} - i \, a^{3}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )\right )}}{d e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, d e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))^3,x, algorithm="fricas")

[Out]

-2*(-12*I*a^3*e^(6*I*d*x + 6*I*c) - 23*I*a^3*e^(4*I*d*x + 4*I*c) - 18*I*a^3*e^(2*I*d*x + 2*I*c) - 5*I*a^3 + 2*
(-I*a^3*e^(8*I*d*x + 8*I*c) - 4*I*a^3*e^(6*I*d*x + 6*I*c) - 6*I*a^3*e^(4*I*d*x + 4*I*c) - 4*I*a^3*e^(2*I*d*x +
 2*I*c) - I*a^3)*log(e^(2*I*d*x + 2*I*c) + 1))/(d*e^(8*I*d*x + 8*I*c) + 4*d*e^(6*I*d*x + 6*I*c) + 6*d*e^(4*I*d
*x + 4*I*c) + 4*d*e^(2*I*d*x + 2*I*c) + d)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 173 vs. \(2 (76) = 152\).

Time = 0.26 (sec) , antiderivative size = 173, normalized size of antiderivative = 1.92 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=\frac {4 i a^{3} \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{d} + \frac {24 i a^{3} e^{6 i c} e^{6 i d x} + 46 i a^{3} e^{4 i c} e^{4 i d x} + 36 i a^{3} e^{2 i c} e^{2 i d x} + 10 i a^{3}}{d e^{8 i c} e^{8 i d x} + 4 d e^{6 i c} e^{6 i d x} + 6 d e^{4 i c} e^{4 i d x} + 4 d e^{2 i c} e^{2 i d x} + d} \]

[In]

integrate(tan(d*x+c)**2*(a+I*a*tan(d*x+c))**3,x)

[Out]

4*I*a**3*log(exp(2*I*d*x) + exp(-2*I*c))/d + (24*I*a**3*exp(6*I*c)*exp(6*I*d*x) + 46*I*a**3*exp(4*I*c)*exp(4*I
*d*x) + 36*I*a**3*exp(2*I*c)*exp(2*I*d*x) + 10*I*a**3)/(d*exp(8*I*c)*exp(8*I*d*x) + 4*d*exp(6*I*c)*exp(6*I*d*x
) + 6*d*exp(4*I*c)*exp(4*I*d*x) + 4*d*exp(2*I*c)*exp(2*I*d*x) + d)

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.91 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-\frac {i \, a^{3} \tan \left (d x + c\right )^{4} + 4 \, a^{3} \tan \left (d x + c\right )^{3} - 8 i \, a^{3} \tan \left (d x + c\right )^{2} + 16 \, {\left (d x + c\right )} a^{3} + 8 i \, a^{3} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) - 16 \, a^{3} \tan \left (d x + c\right )}{4 \, d} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))^3,x, algorithm="maxima")

[Out]

-1/4*(I*a^3*tan(d*x + c)^4 + 4*a^3*tan(d*x + c)^3 - 8*I*a^3*tan(d*x + c)^2 + 16*(d*x + c)*a^3 + 8*I*a^3*log(ta
n(d*x + c)^2 + 1) - 16*a^3*tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 222 vs. \(2 (76) = 152\).

Time = 0.63 (sec) , antiderivative size = 222, normalized size of antiderivative = 2.47 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-\frac {2 \, {\left (-2 i \, a^{3} e^{\left (8 i \, d x + 8 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 8 i \, a^{3} e^{\left (6 i \, d x + 6 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 12 i \, a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 8 i \, a^{3} e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 12 i \, a^{3} e^{\left (6 i \, d x + 6 i \, c\right )} - 23 i \, a^{3} e^{\left (4 i \, d x + 4 i \, c\right )} - 18 i \, a^{3} e^{\left (2 i \, d x + 2 i \, c\right )} - 2 i \, a^{3} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 5 i \, a^{3}\right )}}{d e^{\left (8 i \, d x + 8 i \, c\right )} + 4 \, d e^{\left (6 i \, d x + 6 i \, c\right )} + 6 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 4 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d} \]

[In]

integrate(tan(d*x+c)^2*(a+I*a*tan(d*x+c))^3,x, algorithm="giac")

[Out]

-2*(-2*I*a^3*e^(8*I*d*x + 8*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 8*I*a^3*e^(6*I*d*x + 6*I*c)*log(e^(2*I*d*x + 2
*I*c) + 1) - 12*I*a^3*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 8*I*a^3*e^(2*I*d*x + 2*I*c)*log(e^(2*
I*d*x + 2*I*c) + 1) - 12*I*a^3*e^(6*I*d*x + 6*I*c) - 23*I*a^3*e^(4*I*d*x + 4*I*c) - 18*I*a^3*e^(2*I*d*x + 2*I*
c) - 2*I*a^3*log(e^(2*I*d*x + 2*I*c) + 1) - 5*I*a^3)/(d*e^(8*I*d*x + 8*I*c) + 4*d*e^(6*I*d*x + 6*I*c) + 6*d*e^
(4*I*d*x + 4*I*c) + 4*d*e^(2*I*d*x + 2*I*c) + d)

Mupad [B] (verification not implemented)

Time = 4.46 (sec) , antiderivative size = 73, normalized size of antiderivative = 0.81 \[ \int \tan ^2(c+d x) (a+i a \tan (c+d x))^3 \, dx=-\frac {a^3\,\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,4{}\mathrm {i}-4\,a^3\,\mathrm {tan}\left (c+d\,x\right )-a^3\,{\mathrm {tan}\left (c+d\,x\right )}^2\,2{}\mathrm {i}+a^3\,{\mathrm {tan}\left (c+d\,x\right )}^3+\frac {a^3\,{\mathrm {tan}\left (c+d\,x\right )}^4\,1{}\mathrm {i}}{4}}{d} \]

[In]

int(tan(c + d*x)^2*(a + a*tan(c + d*x)*1i)^3,x)

[Out]

-(a^3*log(tan(c + d*x) + 1i)*4i - 4*a^3*tan(c + d*x) - a^3*tan(c + d*x)^2*2i + a^3*tan(c + d*x)^3 + (a^3*tan(c
 + d*x)^4*1i)/4)/d